package pack;

import java.awt.List;
import java.io.File;
import java.util.Vector;

class Trunk
{
	String path;
	int iByte;
	Vector<Trunk> sons;
	
	public Trunk(String path)
	{
		this.path = path;
		this.iByte = 0;
		sons = new Vector<Trunk>();
	}
}

public class TreeForDirectory
{
	Trunk root;
	
	public TreeForDirectory(String path)
	{
		root = new Trunk(path);
		root.iByte = createTree(root);
	}
	
	private int createTree(Trunk trunk)
	{
		int sizeByte = 0;
		
		File tmp = new File(trunk.path);
		File[] files = tmp.listFiles();
		for(int k = 0; k < files.length; k++)
			if(files[k].isDirectory())
			{
				Trunk tmpTrunk = new Trunk(files[k].getPath());
				tmpTrunk.iByte = createTree(tmpTrunk);
				sizeByte += tmpTrunk.iByte;
				trunk.sons.add(tmpTrunk);
			}
			else
				sizeByte += files[k].length();
	
		return sizeByte;
	}
	
	public void printTree()
	{
		printTree(root, 0);
	}
	
	private void printTree(Trunk trunk, int level)
	{
		for(int k = 0; k < level; k++)
			System.out.print("\t");
		
		System.out.println(trunk.path + " - " + trunk.iByte + "b");
		
		for(int k = 0; k < trunk.sons.size(); k++)
			printTree(trunk.sons.get(k), level+1);
	}
	
	public static void main(String[] args)
	{
		TreeForDirectory tree = new TreeForDirectory("..");
		
		tree.printTree();
	}
}
